package com.family.web.controller.pedigree;


import com.family.common.annotation.Log;
import com.family.common.core.controller.BaseController;
import com.family.common.core.domain.AjaxResult;
import com.family.common.core.page.TableDataInfo;
import com.family.common.enums.BusinessType;
import com.family.pedigree.domain.FamilyProcess;
import com.family.pedigree.service.IFamilyProcessService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 流程定义表 前端控制器
 * </p>
 *
 * @author forever
 * @since 2024-11-24
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/family/process")
public class FamilyProcessController extends BaseController {

    private final IFamilyProcessService productService;

    @Log(title = "添加流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FamilyProcess process){

        productService.add(process);
        return success();
    }

    @Log(title = "修改流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FamilyProcess process){

        productService.edit(process);
        return success();
    }

    @GetMapping("/list")
    public TableDataInfo getList(FamilyProcess process){
        startPage();
        return getDataTable(productService.getList(process));
    }

    @Log(title = "删除流程", businessType = BusinessType.DELETE)
    @DeleteMapping("/{processId}")
    public AjaxResult delById(@PathVariable Long processId){

        productService.delById(processId);
        return success();
    }

}
